<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RBS::CLI - rbs: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-collection_options">#collection_options</a>
    <li ><a href="#method-i-has_parser-3F">#has_parser?</a>
    <li ><a href="#method-i-parse_logging_options">#parse_logging_options</a>
    <li ><a href="#method-i-run">#run</a>
    <li ><a href="#method-i-run_ancestors">#run_ancestors</a>
    <li ><a href="#method-i-run_annotate">#run_annotate</a>
    <li ><a href="#method-i-run_ast">#run_ast</a>
    <li ><a href="#method-i-run_collection">#run_collection</a>
    <li ><a href="#method-i-run_constant">#run_constant</a>
    <li ><a href="#method-i-run_list">#run_list</a>
    <li ><a href="#method-i-run_method">#run_method</a>
    <li ><a href="#method-i-run_methods">#run_methods</a>
    <li ><a href="#method-i-run_parse">#run_parse</a>
    <li ><a href="#method-i-run_paths">#run_paths</a>
    <li ><a href="#method-i-run_prototype">#run_prototype</a>
    <li ><a href="#method-i-run_prototype_file">#run_prototype_file</a>
    <li ><a href="#method-i-run_subtract">#run_subtract</a>
    <li ><a href="#method-i-run_test">#run_test</a>
    <li ><a href="#method-i-run_validate">#run_validate</a>
    <li ><a href="#method-i-run_vendor">#run_vendor</a>
    <li ><a href="#method-i-test_opt">#test_opt</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RBS::CLI">
    <h1 id="class-RBS::CLI" class="class">
      class RBS::CLI
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="COMMANDS">COMMANDS
          <dd>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-original_args" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">original_args</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-stderr" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">stderr</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-stdout" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">stdout</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(stdout:, stderr:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 88</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-value">stdout:</span>, <span class="ruby-value">stderr:</span>)
  <span class="ruby-ivar">@stdout</span> = <span class="ruby-identifier">stdout</span>
  <span class="ruby-ivar">@stderr</span> = <span class="ruby-identifier">stderr</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-collection_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">collection_options</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="collection_options-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 1160</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">collection_options</span>(<span class="ruby-identifier">args</span>)
      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;~HELP</span>
<span class="ruby-value">          Usage: rbs collection [install|update|init|clean|help]

          Manage RBS collection, which contains third party RBS.

          Examples:

            # Initialize the configuration file
            $ rbs collection init

            # Generate the lock file and install RBSs from the lock file
            $ rbs collection install

            # Update the RBSs
            $ rbs collection update

          Options:
</span><span class="ruby-identifier">        HELP</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--frozen&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;install&#39;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-has_parser-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">has_parser?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="has_parser-3F-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 108</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">has_parser?</span>
  <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">RubyVM</span><span class="ruby-operator">::</span><span class="ruby-constant">AbstractSyntaxTree</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parse_logging_options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse_logging_options</span><span
                                class="method-args">(opts)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="parse_logging_options-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 95</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_logging_options</span>(<span class="ruby-identifier">opts</span>)
  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--log-level LEVEL&quot;</span>, <span class="ruby-string">&quot;Specify log level (defaults to `warn`)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">level</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">RBS</span>.<span class="ruby-identifier">logger_level</span> = <span class="ruby-identifier">level</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--log-output OUTPUT&quot;</span>, <span class="ruby-string">&quot;Specify the file to output log (defaults to stderr)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">output</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">io</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">output</span>, <span class="ruby-string">&quot;a&quot;</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>
    <span class="ruby-constant">RBS</span>.<span class="ruby-identifier">logger_output</span> = <span class="ruby-identifier">io</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">opts</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 112</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run</span>(<span class="ruby-identifier">args</span>)
      <span class="ruby-ivar">@original_args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">dup</span>

      <span class="ruby-identifier">options</span> = <span class="ruby-constant">LibraryOptions</span>.<span class="ruby-identifier">new</span>

      <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;~USAGE</span>
<span class="ruby-value">        Usage: rbs [options...] [command...]

        Available commands: #{COMMANDS.join(&quot;, &quot;)}, version, help.

        Options:
</span><span class="ruby-identifier">      USAGE</span>
      <span class="ruby-identifier">options</span>.<span class="ruby-identifier">setup_library_options</span>(<span class="ruby-identifier">opts</span>)
      <span class="ruby-identifier">parse_logging_options</span>(<span class="ruby-identifier">opts</span>)
      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">version</span> = <span class="ruby-constant">RBS</span><span class="ruby-operator">::</span><span class="ruby-constant">VERSION</span>

      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">command</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span>&amp;.<span class="ruby-identifier">to_sym</span>

      <span class="ruby-keyword">case</span> <span class="ruby-identifier">command</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:version</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">ver</span>
      <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">COMMANDS</span>
        <span class="ruby-identifier">__send__</span> <span class="ruby-value">:&quot;run_#{command}&quot;</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_ancestors" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_ancestors</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_ancestors-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 257</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_ancestors</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-comment"># @type var kind: :instance | :singleton</span>
      <span class="ruby-identifier">kind</span> = <span class="ruby-value">:instance</span>

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs ancestors [options...] [type_name]

Show ancestors of the given class or module.

Examples:

  $ rbs ancestors --instance String
  $ rbs ancestors --singleton Array

Options:
</span><span class="ruby-identifier">EOU</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--instance&quot;</span>, <span class="ruby-string">&quot;Ancestors of instance of the given type_name (default)&quot;</span>) { <span class="ruby-identifier">kind</span> = <span class="ruby-value">:instance</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--singleton&quot;</span>, <span class="ruby-string">&quot;Ancestors of singleton of the given type_name&quot;</span>) { <span class="ruby-identifier">kind</span> = <span class="ruby-value">:singleton</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Expected one argument.&quot;</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()

      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-identifier">builder</span> = <span class="ruby-constant">DefinitionBuilder</span><span class="ruby-operator">::</span><span class="ruby-constant">AncestorBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
      <span class="ruby-identifier">type_name</span> = <span class="ruby-constant">TypeName</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">absolute!</span>

      <span class="ruby-keyword">case</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">constant_entry</span>(<span class="ruby-identifier">type_name</span>)
      <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassEntry</span>, <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleEntry</span>, <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassAliasEntry</span>, <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleAliasEntry</span>
        <span class="ruby-identifier">type_name</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">normalize_module_name</span>(<span class="ruby-identifier">type_name</span>)

        <span class="ruby-identifier">ancestors</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">kind</span>
                    <span class="ruby-keyword">when</span> <span class="ruby-value">:instance</span>
                      <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">instance_ancestors</span>(<span class="ruby-identifier">type_name</span>)
                    <span class="ruby-keyword">when</span> <span class="ruby-value">:singleton</span>
                      <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">singleton_ancestors</span>(<span class="ruby-identifier">type_name</span>)
                    <span class="ruby-keyword">else</span>
                      <span class="ruby-identifier">raise</span>
                    <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ancestor</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">ancestor</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Ancestor</span><span class="ruby-operator">::</span><span class="ruby-constant">Singleton</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;singleton(#{ancestor.name})&quot;</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Ancestor</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{ancestor.name}[#{ancestor.args.join(&quot;, &quot;)}]&quot;</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Cannot find class: #{type_name}&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_annotate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_annotate</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_annotate-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 978</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_annotate</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;rbs/annotate&quot;</span>

      <span class="ruby-identifier">source</span> = <span class="ruby-constant">RBS</span><span class="ruby-operator">::</span><span class="ruby-constant">Annotate</span><span class="ruby-operator">::</span><span class="ruby-constant">RDocSource</span>.<span class="ruby-identifier">new</span>()
      <span class="ruby-identifier">annotator</span> = <span class="ruby-constant">RBS</span><span class="ruby-operator">::</span><span class="ruby-constant">Annotate</span><span class="ruby-operator">::</span><span class="ruby-constant">RDocAnnotator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">source:</span> <span class="ruby-identifier">source</span>)

      <span class="ruby-identifier">preserve</span> = <span class="ruby-keyword">true</span>

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;-EOB</span>
<span class="ruby-value">Usage: rbs annotate [options...] [files...]

Import documents from RDoc and update RBS files.

Examples:

  $ rbs annotate stdlib/pathname/**/*.rbs

Options:
</span><span class="ruby-identifier">        EOB</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]system&quot;</span>, <span class="ruby-string">&quot;Load RDoc from system (defaults to true)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">with_system_dir</span> = <span class="ruby-identifier">b</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]gems&quot;</span>, <span class="ruby-string">&quot;Load RDoc from gems (defaults to false)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">with_gems_dir</span> = <span class="ruby-identifier">b</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]site&quot;</span>, <span class="ruby-string">&quot;Load RDoc from site directory (defaults to false)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">with_site_dir</span> = <span class="ruby-identifier">b</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]home&quot;</span>, <span class="ruby-string">&quot;Load RDoc from home directory (defaults to false)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">with_home_dir</span> = <span class="ruby-identifier">b</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-d&quot;</span>, <span class="ruby-string">&quot;--dir DIRNAME&quot;</span>, <span class="ruby-string">&quot;Load RDoc from DIRNAME&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">extra_dirs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">d</span>) }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]arglists&quot;</span>, <span class="ruby-string">&quot;Generate arglists section (defaults to true)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">annotator</span>.<span class="ruby-identifier">include_arg_lists</span> = <span class="ruby-identifier">b</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]filename&quot;</span>, <span class="ruby-string">&quot;Include source file name in the documentation (defaults to true)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">annotator</span>.<span class="ruby-identifier">include_filename</span> = <span class="ruby-identifier">b</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]preserve&quot;</span>, <span class="ruby-string">&quot;Try preserve the format of the original file (defaults to true)&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">preserve</span> = <span class="ruby-identifier">b</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">source</span>.<span class="ruby-identifier">load</span>()

      <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">path</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">file</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">directory?</span>
          <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">glob</span>((<span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;**/*.rbs&quot;</span>).<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Processing #{path}...&quot;</span>
            <span class="ruby-identifier">annotator</span>.<span class="ruby-identifier">annotate_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value">preserve:</span> <span class="ruby-identifier">preserve</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Processing #{path}...&quot;</span>
          <span class="ruby-identifier">annotator</span>.<span class="ruby-identifier">annotate_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value">preserve:</span> <span class="ruby-identifier">preserve</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_ast" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_ast</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_ast-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 143</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_ast</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOB</span>
<span class="ruby-value">Usage: rbs ast [patterns...]

Print JSON AST of loaded environment.
You can specify patterns to filter declarations with the file names.

Examples:

  $ rbs ast
  $ rbs ast &#39;basic_object.rbs&#39;
  $ rbs -I ./sig ast ./sig
  $ rbs -I ./sig ast &#39;*/models/*.rbs&#39;
</span><span class="ruby-identifier">EOB</span>
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">patterns</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">path</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">arg</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">exist?</span>
          <span class="ruby-comment"># Pathname means a directory or a file</span>
          <span class="ruby-identifier">path</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-comment"># String means a `fnmatch` pattern</span>
          <span class="ruby-identifier">arg</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()

      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-identifier">decls</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">declarations</span>.<span class="ruby-identifier">select</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">decl</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">loc</span> = <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>
        <span class="ruby-comment"># @type var name: String</span>
        <span class="ruby-identifier">name</span> = <span class="ruby-identifier">loc</span>.<span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">name</span>

        <span class="ruby-identifier">patterns</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">patterns</span>.<span class="ruby-identifier">any?</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pat</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">pat</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Pathname</span>
            <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">ascend</span>.<span class="ruby-identifier">any?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">pat</span> }
          <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
            <span class="ruby-identifier">name</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-identifier">pat</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">fnmatch</span>(<span class="ruby-identifier">pat</span>, <span class="ruby-identifier">name</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">FNM_EXTGLOB</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">print</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">generate</span>(<span class="ruby-identifier">decls</span>)
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">flush</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_collection" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_collection</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_collection-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 1099</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_collection</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">collection_options</span>(<span class="ruby-identifier">args</span>)
      <span class="ruby-identifier">params</span> = {}
      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">order</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">drop</span>(<span class="ruby-value">1</span>), <span class="ruby-value">into:</span> <span class="ruby-identifier">params</span>
      <span class="ruby-identifier">config_path</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">config_path</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>
      <span class="ruby-identifier">lock_path</span> = <span class="ruby-constant">Collection</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">to_lockfile_path</span>(<span class="ruby-identifier">config_path</span>)

      <span class="ruby-identifier">subcommand</span> = <span class="ruby-constant">Abbrev</span>.<span class="ruby-identifier">abbrev</span>([<span class="ruby-string">&#39;install&#39;</span>, <span class="ruby-string">&#39;update&#39;</span>, <span class="ruby-string">&#39;help&#39;</span>])[<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]] <span class="ruby-operator">||</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">subcommand</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;install&#39;</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:frozen</span>]
          <span class="ruby-constant">Collection</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">generate_lockfile</span>(<span class="ruby-value">config_path:</span> <span class="ruby-identifier">config_path</span>, <span class="ruby-value">definition:</span> <span class="ruby-constant">Bundler</span>.<span class="ruby-identifier">definition</span>)
        <span class="ruby-keyword">end</span>
        <span class="ruby-constant">Collection</span><span class="ruby-operator">::</span><span class="ruby-constant">Installer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">lockfile_path:</span> <span class="ruby-identifier">lock_path</span>, <span class="ruby-value">stdout:</span> <span class="ruby-identifier">stdout</span>).<span class="ruby-identifier">install_from_lockfile</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;update&#39;</span>
        <span class="ruby-comment"># TODO: Be aware of argv to update only specified gem</span>
        <span class="ruby-constant">Collection</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">generate_lockfile</span>(<span class="ruby-value">config_path:</span> <span class="ruby-identifier">config_path</span>, <span class="ruby-value">definition:</span> <span class="ruby-constant">Bundler</span>.<span class="ruby-identifier">definition</span>, <span class="ruby-value">with_lockfile:</span> <span class="ruby-keyword">false</span>)
        <span class="ruby-constant">Collection</span><span class="ruby-operator">::</span><span class="ruby-constant">Installer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">lockfile_path:</span> <span class="ruby-identifier">lock_path</span>, <span class="ruby-value">stdout:</span> <span class="ruby-identifier">stdout</span>).<span class="ruby-identifier">install_from_lockfile</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;init&#39;</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">config_path</span>.<span class="ruby-identifier">exist?</span>
          <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{config_path} already exists&quot;</span>
          <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">config_path</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">&lt;&lt;~&#39;YAML&#39;</span>)
<span class="ruby-value">          # Download sources
          sources:
            - type: git
              name: ruby/gem_rbs_collection
              remote: https://github.com/ruby/gem_rbs_collection.git
              revision: main
              repo_dir: gems

          # You can specify local directories as sources also.
          # - type: local
          #   path: path/to/your/local/repository

          # A directory to install the downloaded RBSs
          path: .gem_rbs_collection

          gems:
            # Skip loading rbs gem&#39;s RBS.
            # It&#39;s unnecessary if you don&#39;t use rbs as a library.
            - name: rbs
              ignore: true
</span><span class="ruby-identifier">        YAML</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;created: #{config_path}&quot;</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;clean&#39;</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">lock_path</span>.<span class="ruby-identifier">exist?</span>
          <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{lock_path} should exist to clean&quot;</span>
          <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-constant">Collection</span><span class="ruby-operator">::</span><span class="ruby-constant">Cleaner</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">lockfile_path:</span> <span class="ruby-identifier">lock_path</span>)
      <span class="ruby-keyword">when</span> <span class="ruby-string">&#39;help&#39;</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
        <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_constant" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_constant</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_constant-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 537</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_constant</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-comment"># @type var context: String?</span>
      <span class="ruby-identifier">context</span> = <span class="ruby-keyword">nil</span>

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs constant [options...] [name]

Resolve constant based on RBS.

Examples:

  $ rbs constant ::Object
  $ rbs constant UTF_8
  $ rbs constant --context=::Encoding UTF_8

Options:
</span><span class="ruby-identifier">EOU</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--context CONTEXT&quot;</span>, <span class="ruby-string">&quot;Name of the module where the constant resolution starts&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">context</span> = <span class="ruby-identifier">c</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Expected one argument.&quot;</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()
      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-identifier">builder</span> = <span class="ruby-constant">DefinitionBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
      <span class="ruby-identifier">resolver</span> = <span class="ruby-constant">Resolver</span><span class="ruby-operator">::</span><span class="ruby-constant">ConstantResolver</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">builder:</span> <span class="ruby-identifier">builder</span>)

      <span class="ruby-identifier">resolver_context</span> = <span class="ruby-identifier">context</span> <span class="ruby-operator">?</span> [<span class="ruby-keyword">nil</span>, <span class="ruby-constant">TypeName</span>(<span class="ruby-identifier">context</span>).<span class="ruby-identifier">absolute!</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span> <span class="ruby-comment">#: Resolver::context</span>
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Context: #{context}&quot;</span>
      <span class="ruby-identifier">const_name</span> = <span class="ruby-constant">TypeName</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Constant name: #{const_name}&quot;</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">const_name</span>.<span class="ruby-identifier">absolute?</span>
        <span class="ruby-identifier">constant</span> = <span class="ruby-identifier">resolver</span>.<span class="ruby-identifier">table</span>.<span class="ruby-identifier">constant</span>(<span class="ruby-identifier">const_name</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">head</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">components</span> = <span class="ruby-identifier">const_name</span>.<span class="ruby-identifier">to_namespace</span>.<span class="ruby-identifier">path</span>
        <span class="ruby-identifier">head</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>

        <span class="ruby-identifier">constant</span> = <span class="ruby-identifier">resolver</span>.<span class="ruby-identifier">resolve</span>(<span class="ruby-identifier">head</span>, <span class="ruby-value">context:</span> <span class="ruby-identifier">resolver_context</span>)
        <span class="ruby-identifier">constant</span> = <span class="ruby-identifier">components</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">constant</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">const</span>, <span class="ruby-identifier">component</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">const</span>
            <span class="ruby-identifier">resolver</span>.<span class="ruby-identifier">resolve_child</span>(<span class="ruby-identifier">const</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">component</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">constant</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot; =&gt; #{constant.name}: #{constant.type}&quot;</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot; =&gt; [no constant]&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_list" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_list</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_list-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 194</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_list</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-comment"># @type var list: Set[:class | :module | :interface]</span>
      <span class="ruby-identifier">list</span> = <span class="ruby-constant">Set</span>[]

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOB</span>
<span class="ruby-value">Usage: rbs list [options...]

List classes, modules, and interfaces.

Examples:

  $ rbs list
  $ rbs list --class --module --interface

Options:
</span><span class="ruby-identifier">EOB</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--class&quot;</span>, <span class="ruby-string">&quot;List classes&quot;</span>) { <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:class</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--module&quot;</span>, <span class="ruby-string">&quot;List modules&quot;</span>) { <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:module</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--interface&quot;</span>, <span class="ruby-string">&quot;List interfaces&quot;</span>) { <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">:interface</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">list</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">_</span> = [<span class="ruby-value">:class</span>, <span class="ruby-value">:module</span>, <span class="ruby-value">:interface</span>]) <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">empty?</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()

      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:class</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:module</span>)
        <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">entry</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleEntry</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:module</span>)
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{name} (module)&quot;</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassEntry</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:class</span>)
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{name} (class)&quot;</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_alias_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">entry</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleAliasEntry</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:module</span>)
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{name} (module alias)&quot;</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassAliasEntry</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:class</span>)
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{name} (class alias)&quot;</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:interface</span>)
        <span class="ruby-identifier">env</span>.<span class="ruby-identifier">interface_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{name} (interface)&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_method" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_method</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_method-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 376</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_method</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-comment"># @type var kind: :instance | :singleton</span>
      <span class="ruby-identifier">kind</span> = <span class="ruby-value">:instance</span>

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs method [options...] [type_name] [method_name]

Show the information of the method specified by type_name and method_name.

Examples:

  $ rbs method --instance Kernel puts
  $ rbs method --singleton String try_convert

Options:
</span><span class="ruby-identifier">EOU</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--instance&quot;</span>, <span class="ruby-string">&quot;Show an instance method (default)&quot;</span>) { <span class="ruby-identifier">kind</span> = <span class="ruby-value">:instance</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--singleton&quot;</span>, <span class="ruby-string">&quot;Show a singleton method&quot;</span>) { <span class="ruby-identifier">kind</span> = <span class="ruby-value">:singleton</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Expected two arguments, but given #{args.size}.&quot;</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()
      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-identifier">builder</span> = <span class="ruby-constant">DefinitionBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
      <span class="ruby-identifier">type_name</span> = <span class="ruby-constant">TypeName</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">absolute!</span>
      <span class="ruby-identifier">method_name</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_sym</span>

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">module_name?</span>(<span class="ruby-identifier">type_name</span>)
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Cannot find class: #{type_name}&quot;</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">definition</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">kind</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-value">:instance</span>
                     <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">type_name</span>)
                   <span class="ruby-keyword">when</span> <span class="ruby-value">:singleton</span>
                     <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_singleton</span>(<span class="ruby-identifier">type_name</span>)
                   <span class="ruby-keyword">else</span>
                     <span class="ruby-identifier">raise</span>
                   <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">method</span> = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method_name</span>]

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">method</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Cannot find method: #{method_name}&quot;</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{type_name}#{kind == :instance ? &quot;#&quot; : &quot;.&quot;}#{method_name}&quot;</span>
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  defined_in: #{method.defined_in}&quot;</span>
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  implementation: #{method.implemented_in}&quot;</span>
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  accessibility: #{method.accessibility}&quot;</span>
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;  types:&quot;</span>
      <span class="ruby-identifier">separator</span> = <span class="ruby-string">&quot; &quot;</span>
      <span class="ruby-keyword">for</span> <span class="ruby-identifier">type</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">method_types</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;    #{separator} #{type}&quot;</span>
        <span class="ruby-identifier">separator</span> = <span class="ruby-string">&quot;|&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_methods" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_methods</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_methods-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 320</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_methods</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-comment"># @type var kind: :instance | :singleton</span>
      <span class="ruby-identifier">kind</span> = <span class="ruby-value">:instance</span>
      <span class="ruby-identifier">inherit</span> = <span class="ruby-keyword">true</span>

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs methods [options...] [type_name]

Show methods defined in the class or module.

Examples:

  $ rbs methods --instance Kernel
  $ rbs methods --singleton --no-inherit String

Options:
</span><span class="ruby-identifier">EOU</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--instance&quot;</span>, <span class="ruby-string">&quot;Show instance methods (default)&quot;</span>) { <span class="ruby-identifier">kind</span> = <span class="ruby-value">:instance</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--singleton&quot;</span>, <span class="ruby-string">&quot;Show singleton methods&quot;</span>) { <span class="ruby-identifier">kind</span> = <span class="ruby-value">:singleton</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]inherit&quot;</span>, <span class="ruby-string">&quot;Show methods defined in super class and mixed modules too&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">inherit</span> = <span class="ruby-identifier">v</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Expected one argument.&quot;</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()

      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-identifier">builder</span> = <span class="ruby-constant">DefinitionBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
      <span class="ruby-identifier">type_name</span> = <span class="ruby-constant">TypeName</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">absolute!</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">module_name?</span>(<span class="ruby-identifier">type_name</span>)
        <span class="ruby-identifier">definition</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">kind</span>
                     <span class="ruby-keyword">when</span> <span class="ruby-value">:instance</span>
                       <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">type_name</span>)
                     <span class="ruby-keyword">when</span> <span class="ruby-value">:singleton</span>
                       <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_singleton</span>(<span class="ruby-identifier">type_name</span>)
                     <span class="ruby-keyword">else</span>
                       <span class="ruby-identifier">raise</span>
                     <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">method</span> = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-identifier">name</span>]
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">inherit</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">implemented_in</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">type_name</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{name} (#{method.accessibility})&quot;</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Cannot find class: #{type_name}&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_parse" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_parse</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_parse-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 930</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_parse</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-identifier">parse_method</span> = <span class="ruby-value">:parse_signature</span>
      <span class="ruby-comment"># @type var e_code: String?</span>
      <span class="ruby-identifier">e_code</span> = <span class="ruby-keyword">nil</span>

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;-EOB</span>
<span class="ruby-value">Usage: rbs parse [files...]

Parse given RBS files and print syntax errors.

Examples:

  $ rbs parse sig/app/models.rbs sig/app/controllers.rbs

Options:
</span><span class="ruby-identifier">        EOB</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;-e CODE&#39;</span>, <span class="ruby-string">&#39;One line RBS script to parse&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e_code</span> = <span class="ruby-identifier">e</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--type&#39;</span>, <span class="ruby-string">&#39;Parse code as a type&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">parse_method</span> = <span class="ruby-value">:parse_type</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--method-type&#39;</span>, <span class="ruby-string">&#39;Parse code as a method type&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">parse_method</span> = <span class="ruby-value">:parse_method_type</span> }
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">syntax_error</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">bufs</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">flat_map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">path</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">path</span>)
        <span class="ruby-constant">FileFinder</span>.<span class="ruby-identifier">each_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value">skip_hidden:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">immediate:</span> <span class="ruby-keyword">true</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file_path</span><span class="ruby-operator">|</span>
          <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">content:</span> <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">read</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">file_path</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">bufs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">content:</span> <span class="ruby-identifier">e_code</span>, <span class="ruby-value">name:</span> <span class="ruby-string">&#39;-e&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">e_code</span>

      <span class="ruby-identifier">bufs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">buf</span><span class="ruby-operator">|</span>
        <span class="ruby-constant">RBS</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">&quot;Parsing #{buf.name}...&quot;</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">parse_method</span>
        <span class="ruby-keyword">when</span> <span class="ruby-value">:parse_signature</span>
          <span class="ruby-constant">Parser</span>.<span class="ruby-identifier">parse_signature</span>(<span class="ruby-identifier">buf</span>)
        <span class="ruby-keyword">else</span>
          <span class="ruby-constant">Parser</span>.<span class="ruby-identifier">public_send</span>(<span class="ruby-identifier">parse_method</span>, <span class="ruby-identifier">buf</span>, <span class="ruby-value">require_eof:</span> <span class="ruby-keyword">true</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">RBS</span><span class="ruby-operator">::</span><span class="ruby-constant">ParsingError</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">ex</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">detailed_message</span>(<span class="ruby-value">highlight:</span> <span class="ruby-keyword">true</span>)
        <span class="ruby-identifier">syntax_error</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">syntax_error</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_paths" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_paths</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_paths-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 595</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_paths</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs paths

Show paths to directories where the RBS files are loaded from.

Examples:

  $ rbs paths
  $ rbs -r set paths
</span><span class="ruby-identifier">EOU</span>
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()

      <span class="ruby-identifier">kind_of</span> = <span class="ruby-operator">-&gt;</span> (<span class="ruby-identifier">path</span>) {
        <span class="ruby-comment"># @type var path: Pathname</span>
        <span class="ruby-keyword">case</span>
        <span class="ruby-keyword">when</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">file?</span>
          <span class="ruby-string">&quot;file&quot;</span>
        <span class="ruby-keyword">when</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">directory?</span>
          <span class="ruby-string">&quot;dir&quot;</span>
        <span class="ruby-keyword">when</span> <span class="ruby-operator">!</span><span class="ruby-identifier">path</span>.<span class="ruby-identifier">exist?</span>
          <span class="ruby-string">&quot;absent&quot;</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-string">&quot;unknown&quot;</span>
        <span class="ruby-keyword">end</span>
      }

      <span class="ruby-identifier">loader</span>.<span class="ruby-identifier">each_dir</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">source</span>, <span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">source</span>
        <span class="ruby-keyword">when</span> <span class="ruby-value">:core</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{dir} (#{kind_of[dir]}, core)&quot;</span>
        <span class="ruby-keyword">when</span> <span class="ruby-constant">Pathname</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{dir} (#{kind_of[dir]})&quot;</span>
        <span class="ruby-keyword">when</span> <span class="ruby-constant">EnvironmentLoader</span><span class="ruby-operator">::</span><span class="ruby-constant">Library</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{dir} (#{kind_of[dir]}, library, name=#{source.name})&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_prototype" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_prototype</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_prototype-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 637</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_prototype</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-identifier">format</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span>

      <span class="ruby-keyword">case</span> <span class="ruby-identifier">format</span>
      <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;rbi&quot;</span>, <span class="ruby-string">&quot;rb&quot;</span>
        <span class="ruby-identifier">run_prototype_file</span>(<span class="ruby-identifier">format</span>, <span class="ruby-identifier">args</span>)
      <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;runtime&quot;</span>
        <span class="ruby-identifier">require_libs</span> = []
        <span class="ruby-identifier">relative_libs</span> = []
        <span class="ruby-identifier">merge</span> = <span class="ruby-keyword">false</span>
        <span class="ruby-identifier">owners_included</span> = []
        <span class="ruby-identifier">outline</span> = <span class="ruby-keyword">false</span>

        <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs prototype runtime [options...] [pattern...]

Generate RBS prototype based on runtime introspection.
It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].

Examples:

  $ rbs prototype runtime String
  $ rbs prototype runtime --require set Set
  $ rbs prototype runtime -R lib/rbs RBS RBS::*

Options:
</span><span class="ruby-identifier">EOU</span>
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-r&quot;</span>, <span class="ruby-string">&quot;--require LIB&quot;</span>, <span class="ruby-string">&quot;Load library using `require`&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">require_libs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">lib</span>
          <span class="ruby-keyword">end</span>
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;-R&quot;</span>, <span class="ruby-string">&quot;--require-relative LIB&quot;</span>, <span class="ruby-string">&quot;Load library using `require_relative`&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">relative_libs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">lib</span>
          <span class="ruby-keyword">end</span>
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--merge&quot;</span>, <span class="ruby-string">&quot;Merge generated prototype RBS with existing RBS&quot;</span>) <span class="ruby-keyword">do</span>
            <span class="ruby-identifier">merge</span> = <span class="ruby-keyword">true</span>
          <span class="ruby-keyword">end</span>
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--method-owner CLASS&quot;</span>, <span class="ruby-string">&quot;Generate method prototypes if the owner of the method is [CLASS]&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">owners_included</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">klass</span>
          <span class="ruby-keyword">end</span>
          <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--outline&quot;</span>, <span class="ruby-string">&quot;Generates only module/class/constant declaration (no method definition)&quot;</span>) <span class="ruby-keyword">do</span>
            <span class="ruby-identifier">outline</span> = <span class="ruby-keyword">true</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

        <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()
        <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

        <span class="ruby-identifier">require_libs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">require</span>(<span class="ruby-identifier">lib</span>)
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">relative_libs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">eval</span>(<span class="ruby-string">&quot;require_relative(lib)&quot;</span>, <span class="ruby-identifier">binding</span>, <span class="ruby-string">&quot;rbs&quot;</span>)
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">runtime</span> = <span class="ruby-constant">Prototype</span><span class="ruby-operator">::</span><span class="ruby-constant">Runtime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">patterns:</span> <span class="ruby-identifier">args</span>, <span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>, <span class="ruby-value">merge:</span> <span class="ruby-identifier">merge</span>, <span class="ruby-value">owners_included:</span> <span class="ruby-identifier">owners_included</span>)
        <span class="ruby-identifier">runtime</span>.<span class="ruby-identifier">outline</span> = <span class="ruby-identifier">outline</span>

        <span class="ruby-identifier">decls</span> = <span class="ruby-identifier">runtime</span>.<span class="ruby-identifier">decls</span>

        <span class="ruby-identifier">writer</span> = <span class="ruby-constant">Writer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">out:</span> <span class="ruby-identifier">stdout</span>)
        <span class="ruby-identifier">writer</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">decls</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs prototype [generator...] [args...]

Generate prototype of RBS files.
Supported generators are rb, rbi, runtime.

Examples:

  $ rbs prototype rb foo.rb
  $ rbs prototype rbi foo.rbi
  $ rbs prototype runtime String
</span><span class="ruby-identifier">EOU</span>
        <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_prototype_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_prototype_file</span><span
                                class="method-args">(format, args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_prototype_file-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 717</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_prototype_file</span>(<span class="ruby-identifier">format</span>, <span class="ruby-identifier">args</span>)
      <span class="ruby-identifier">availability</span> = <span class="ruby-keyword">unless</span> <span class="ruby-identifier">has_parser?</span>
                       <span class="ruby-node">&quot;\n** This command does not work on this interpreter (#{RUBY_ENGINE}) **\n&quot;</span>
                     <span class="ruby-keyword">end</span>

      <span class="ruby-comment"># @type var output_dir: Pathname?</span>
      <span class="ruby-identifier">output_dir</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-comment"># @type var base_dir: Pathname?</span>
      <span class="ruby-identifier">base_dir</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-comment"># @type var force: bool</span>
      <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>

      <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs prototype #{format} [files...]
#{availability}
Generate RBS prototype from source code.
It parses specified Ruby code and and generates RBS prototypes.

It only works on MRI because it parses Ruby code with `RubyVM::AbstractSyntaxTree`.

Examples:

  $ rbs prototype rb lib/foo.rb
  $ rbs prototype rbi sorbet/rbi/foo.rbi

You can run the tool in *batch* mode by passing `--out-dir` option.

  $ rbs prototype rb --out-dir=sig lib/foo.rb
  $ rbs prototype rbi --out-dir=sig/models --base-dir=app/models app/models
</span><span class="ruby-identifier">EOU</span>

      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--out-dir=DIR&quot;</span>, <span class="ruby-string">&quot;Specify the path to save the generated RBS files&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">output_dir</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">path</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--base-dir=DIR&quot;</span>, <span class="ruby-string">&quot;Specify the path to calculate the relative path to save the generated RBS files&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">base_dir</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">path</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--force&quot;</span>, <span class="ruby-string">&quot;Overwrite existing RBS files&quot;</span>) <span class="ruby-keyword">do</span>
        <span class="ruby-identifier">force</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">has_parser?</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Not supported on this interpreter (#{RUBY_ENGINE}).&quot;</span>
        <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
        <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">new_parser</span> = <span class="ruby-operator">-&gt;</span> <span class="ruby-keyword">do</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">format</span>
        <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;rbi&quot;</span>
          <span class="ruby-constant">Prototype</span><span class="ruby-operator">::</span><span class="ruby-constant">RBI</span>.<span class="ruby-identifier">new</span>()
        <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;rb&quot;</span>
          <span class="ruby-constant">Prototype</span><span class="ruby-operator">::</span><span class="ruby-constant">RB</span>.<span class="ruby-identifier">new</span>()
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">raise</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">input_paths</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span> <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">arg</span>) }

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">output_dir</span>
        <span class="ruby-comment"># @type var skip_paths: Array[Pathname]</span>
        <span class="ruby-identifier">skip_paths</span> = []

        <span class="ruby-comment"># batch mode</span>
        <span class="ruby-identifier">input_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Processing `#{path}`...&quot;</span>
          <span class="ruby-identifier">ruby_files</span> =
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">file?</span>
              [<span class="ruby-identifier">path</span>]
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">path</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;**/*.rb&quot;</span>).<span class="ruby-identifier">sort</span>
            <span class="ruby-keyword">end</span>

          <span class="ruby-identifier">ruby_files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file_path</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  Generating RBS for `#{file_path}`...&quot;</span>

            <span class="ruby-identifier">relative_path</span> =
              <span class="ruby-keyword">if</span> <span class="ruby-identifier">base_dir</span>
                <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">relative_path_from</span>(<span class="ruby-identifier">base_dir</span>)
              <span class="ruby-keyword">else</span>
                <span class="ruby-keyword">if</span> <span class="ruby-identifier">top</span> = <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">descend</span>.<span class="ruby-identifier">first</span>
                  <span class="ruby-keyword">case</span>
                  <span class="ruby-keyword">when</span> <span class="ruby-identifier">top</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Pathname</span>(<span class="ruby-string">&quot;lib&quot;</span>)
                    <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">relative_path_from</span>(<span class="ruby-identifier">top</span>)
                  <span class="ruby-keyword">when</span> <span class="ruby-identifier">top</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Pathname</span>(<span class="ruby-string">&quot;app&quot;</span>)
                    <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">relative_path_from</span>(<span class="ruby-identifier">top</span>)
                  <span class="ruby-keyword">else</span>
                    <span class="ruby-identifier">file_path</span>
                  <span class="ruby-keyword">end</span>
                <span class="ruby-keyword">else</span>
                  <span class="ruby-identifier">file_path</span>
                <span class="ruby-keyword">end</span>
              <span class="ruby-keyword">end</span>
            <span class="ruby-identifier">relative_path</span> = <span class="ruby-identifier">relative_path</span>.<span class="ruby-identifier">cleanpath</span>()

            <span class="ruby-keyword">if</span> <span class="ruby-identifier">relative_path</span>.<span class="ruby-identifier">absolute?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">relative_path</span>.<span class="ruby-identifier">descend</span>.<span class="ruby-identifier">first</span>&amp;.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;..&quot;</span>
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  ⚠️  Cannot write the RBS to outside of the output dir: `#{relative_path}`&quot;</span>
              <span class="ruby-keyword">next</span>
            <span class="ruby-keyword">end</span>

            <span class="ruby-identifier">output_path</span> = (<span class="ruby-identifier">output_dir</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">relative_path</span>).<span class="ruby-identifier">sub_ext</span>(<span class="ruby-string">&quot;.rbs&quot;</span>)

            <span class="ruby-identifier">parser</span> = <span class="ruby-identifier">new_parser</span>[]
            <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">file_path</span>.<span class="ruby-identifier">read</span>()

            <span class="ruby-keyword">if</span> <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">file?</span>
              <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
                <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;    - Writing RBS to existing file `#{output_path}`...&quot;</span>
              <span class="ruby-keyword">else</span>
                <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;    - Skipping existing file `#{output_path}`...&quot;</span>
                <span class="ruby-identifier">skip_paths</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">file_path</span>
                <span class="ruby-keyword">next</span>
              <span class="ruby-keyword">end</span>
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;    - Writing RBS to `#{output_path}`...&quot;</span>
            <span class="ruby-keyword">end</span>

            (<span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">parent</span>).<span class="ruby-identifier">mkpath</span>
            <span class="ruby-identifier">output_path</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;w&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
              <span class="ruby-identifier">writer</span> = <span class="ruby-constant">Writer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">out:</span> <span class="ruby-identifier">io</span>)
              <span class="ruby-identifier">writer</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">decls</span>)
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">skip_paths</span>.<span class="ruby-identifier">empty?</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;&gt;&gt;&gt;&gt; Skipped existing #{skip_paths.size} files. Use `--force` option to update the files.&quot;</span>
          <span class="ruby-identifier">command</span> = <span class="ruby-identifier">original_args</span>.<span class="ruby-identifier">take</span>(<span class="ruby-identifier">original_args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">input_paths</span>.<span class="ruby-identifier">size</span>)

          <span class="ruby-identifier">skip_paths</span>.<span class="ruby-identifier">take</span>(<span class="ruby-value">10</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  #{defined?(Bundler) ? &quot;bundle exec &quot; : &quot;&quot;}rbs #{Shellwords.join(command)} --force #{Shellwords.escape(path.to_s)}&quot;</span>
          <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">skip_paths</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">10</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;  ...&quot;</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-comment"># file mode</span>
        <span class="ruby-identifier">parser</span> = <span class="ruby-identifier">new_parser</span>[]

        <span class="ruby-identifier">input_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">read</span>()
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">writer</span> = <span class="ruby-constant">Writer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">out:</span> <span class="ruby-identifier">stdout</span>)
        <span class="ruby-identifier">writer</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">decls</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_subtract" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_subtract</span><span
                                class="method-args">(args, _)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_subtract-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 1184</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_subtract</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">_</span>)
      <span class="ruby-identifier">write_to_file</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-comment"># @type var subtrahend_paths: Array[String]</span>
      <span class="ruby-identifier">subtrahend_paths</span> = []

      <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;~HELP</span>
<span class="ruby-value">          Usage:
            rbs subtract [options...] minuend.rbs [minuend2.rbs, ...] subtrahend.rbs
            rbs subtract [options...] minuend.rbs [minuend2.rbs, ...] --subtrahend subtrahend_1.rbs --subtrahend subtrahend_2.rbs

          Remove duplications between RBS files.

          Examples:

            # Generate RBS files from the codebase.
            $ rbs prototype rb lib/ &gt; generated.rbs

            # Write more descrictive types by hand.
            $ $EDITOR handwritten.rbs

            # Remove hand-written method definitions from generated.rbs.
            $ rbs subtract --write generated.rbs handwritten.rbs

          Options:
</span><span class="ruby-identifier">        HELP</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;-w&#39;</span>, <span class="ruby-string">&#39;--write&#39;</span>, <span class="ruby-string">&#39;Overwrite files directry&#39;</span>) { <span class="ruby-identifier">write_to_file</span> = <span class="ruby-keyword">true</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&#39;--subtrahend=PATH&#39;</span>, <span class="ruby-string">&#39;&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-identifier">subtrahend_paths</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">path</span> }
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">subtrahend_paths</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-operator">*</span><span class="ruby-identifier">minuend_paths</span>, <span class="ruby-identifier">subtrahend_path</span> = <span class="ruby-identifier">args</span>
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">subtrahend_path</span>
          <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
          <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">subtrahend_paths</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">subtrahend_path</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">minuend_paths</span> = <span class="ruby-identifier">args</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">minuend_paths</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
        <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">subtrahend</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">env</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">loader</span> = <span class="ruby-constant">EnvironmentLoader</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">core_root:</span> <span class="ruby-keyword">nil</span>)
        <span class="ruby-identifier">subtrahend_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">loader</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">path:</span> <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">path</span>))
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">loader</span>.<span class="ruby-identifier">load</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">minuend_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">minuend_path</span><span class="ruby-operator">|</span>
        <span class="ruby-constant">FileFinder</span>.<span class="ruby-identifier">each_file</span>(<span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">minuend_path</span>), <span class="ruby-value">immediate:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">skip_hidden:</span> <span class="ruby-keyword">true</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rbs_path</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">buf</span> = <span class="ruby-constant">Buffer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">rbs_path</span>, <span class="ruby-value">content:</span> <span class="ruby-identifier">rbs_path</span>.<span class="ruby-identifier">read</span>)
          <span class="ruby-identifier">_</span>, <span class="ruby-identifier">dirs</span>, <span class="ruby-identifier">decls</span> = <span class="ruby-constant">Parser</span>.<span class="ruby-identifier">parse_signature</span>(<span class="ruby-identifier">buf</span>)
          <span class="ruby-identifier">subtracted</span> = <span class="ruby-constant">Subtractor</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">decls</span>, <span class="ruby-identifier">subtrahend</span>).<span class="ruby-identifier">call</span>

          <span class="ruby-identifier">io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
          <span class="ruby-identifier">w</span> = <span class="ruby-constant">Writer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">out:</span> <span class="ruby-identifier">io</span>)
          <span class="ruby-identifier">w</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">dirs</span>)
          <span class="ruby-identifier">w</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">subtracted</span>)

          <span class="ruby-keyword">if</span> <span class="ruby-identifier">write_to_file</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">string</span>.<span class="ruby-identifier">empty?</span>
              <span class="ruby-identifier">rbs_path</span>.<span class="ruby-identifier">delete</span>
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">rbs_path</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">io</span>.<span class="ruby-identifier">string</span>)
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">io</span>.<span class="ruby-identifier">string</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_test" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_test</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_test-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 1035</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_test</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-comment"># @type var unchecked_classes: Array[String]</span>
      <span class="ruby-identifier">unchecked_classes</span> = []
      <span class="ruby-comment"># @type var targets: Array[String]</span>
      <span class="ruby-identifier">targets</span> = []
      <span class="ruby-comment"># @type var sample_size: String?</span>
      <span class="ruby-identifier">sample_size</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-comment"># @type var double_suite: String?</span>
      <span class="ruby-identifier">double_suite</span> = <span class="ruby-keyword">nil</span>

      (<span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOB</span>
<span class="ruby-value">Usage: rbs [rbs options...] test [test options...] COMMAND

Examples:

  $ rbs test rake test
  $ rbs --log-level=debug test --target SomeModule::* rspec
  $ rbs test --target SomeModule::* --target AnotherModule::* --target SomeClass rake test

Options:
</span><span class="ruby-identifier">EOB</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--target TARGET&quot;</span>, <span class="ruby-string">&quot;Sets the runtime test target&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">target</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">targets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">target</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--sample-size SAMPLE_SIZE&quot;</span>, <span class="ruby-string">&quot;Sets the sample size&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">size</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">sample_size</span> = <span class="ruby-identifier">size</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--unchecked-class UNCHECKED_CLASS&quot;</span>, <span class="ruby-string">&quot;Sets the class that would not be checked&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">unchecked_class</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">unchecked_classes</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">unchecked_class</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--double-suite DOUBLE_SUITE&quot;</span>, <span class="ruby-string">&quot;Sets the double suite in use (currently supported: rspec | minitest)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">suite</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">double_suite</span> = <span class="ruby-identifier">suite</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>).<span class="ruby-identifier">order!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">zero?</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">help</span>
        <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-comment"># @type var env_hash: Hash[String, String?]</span>
      <span class="ruby-identifier">env_hash</span> = {
        <span class="ruby-string">&#39;RUBYOPT&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-node">&quot;#{ENV[&#39;RUBYOPT&#39;]} -rrbs/test/setup&quot;</span>,
        <span class="ruby-string">&#39;RBS_TEST_OPT&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">test_opt</span>(<span class="ruby-identifier">options</span>),
        <span class="ruby-string">&#39;RBS_TEST_LOGLEVEL&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-node">%w(DEBUG INFO WARN ERROR FATAL)</span>[<span class="ruby-constant">RBS</span>.<span class="ruby-identifier">logger_level</span> <span class="ruby-operator">||</span> <span class="ruby-value">5</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&quot;UNKNOWN&quot;</span>,
        <span class="ruby-string">&#39;RBS_TEST_SAMPLE_SIZE&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">sample_size</span>,
        <span class="ruby-string">&#39;RBS_TEST_DOUBLE_SUITE&#39;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">double_suite</span>,
        <span class="ruby-string">&#39;RBS_TEST_UNCHECKED_CLASSES&#39;</span> <span class="ruby-operator">=&gt;</span> (<span class="ruby-identifier">unchecked_classes</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;,&#39;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">unchecked_classes</span>.<span class="ruby-identifier">empty?</span>),
        <span class="ruby-string">&#39;RBS_TEST_TARGET&#39;</span> <span class="ruby-operator">=&gt;</span> (<span class="ruby-identifier">targets</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;,&#39;</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">targets</span>.<span class="ruby-identifier">empty?</span>)
      }

      <span class="ruby-comment"># @type var out: String</span>
      <span class="ruby-comment"># @type var err: String</span>
      <span class="ruby-identifier">out</span>, <span class="ruby-identifier">err</span>, <span class="ruby-identifier">status</span> = <span class="ruby-identifier">__skip__</span> = <span class="ruby-constant">Open3</span>.<span class="ruby-identifier">capture3</span>(<span class="ruby-identifier">env_hash</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">out</span>)
      <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">err</span>)

      <span class="ruby-identifier">status</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_validate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_validate</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_validate-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 442</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_validate</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;EOU</span>
<span class="ruby-value">Usage: rbs validate

Validate RBS files. It ensures the type names in RBS files are present and the type applications have correct arity.

Examples:

  $ rbs validate
</span><span class="ruby-identifier">EOU</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--silent&quot;</span>) <span class="ruby-keyword">do</span>
          <span class="ruby-ivar">@stdout</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()
      <span class="ruby-identifier">env</span> = <span class="ruby-constant">Environment</span>.<span class="ruby-identifier">from_loader</span>(<span class="ruby-identifier">loader</span>).<span class="ruby-identifier">resolve_type_names</span>

      <span class="ruby-identifier">builder</span> = <span class="ruby-constant">DefinitionBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
      <span class="ruby-identifier">validator</span> = <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>, <span class="ruby-value">resolver:</span> <span class="ruby-constant">Resolver</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeNameResolver</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>))

      <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">decl</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Validating class/module definition: `#{name}`...&quot;</span>
        <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">each_type</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type</span> <span class="ruby-identifier">type</span>, <span class="ruby-value">context:</span> <span class="ruby-keyword">nil</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_singleton</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">each_type</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type</span> <span class="ruby-identifier">type</span>, <span class="ruby-value">context:</span> <span class="ruby-keyword">nil</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">d</span> = <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">primary</span>.<span class="ruby-identifier">decl</span>

        <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type_params</span>(
          <span class="ruby-identifier">d</span>.<span class="ruby-identifier">type_params</span>,
          <span class="ruby-value">type_name:</span> <span class="ruby-identifier">name</span>,
          <span class="ruby-value">location:</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">location</span>&amp;.<span class="ruby-identifier">aref</span>(<span class="ruby-value">:type_params</span>)
        )

        <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">d</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">each_member</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">member</span><span class="ruby-operator">|</span>
            <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>
            <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">MethodDefinition</span>
              <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_method_definition</span>(<span class="ruby-identifier">member</span>, <span class="ruby-value">type_name:</span> <span class="ruby-identifier">name</span>)
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_alias_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Validating class/module alias definition: `#{name}`...&quot;</span>
        <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_class_alias</span>(<span class="ruby-value">entry:</span> <span class="ruby-identifier">entry</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">env</span>.<span class="ruby-identifier">interface_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">decl</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Validating interface: `#{name}`...&quot;</span>
        <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">build_interface</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">each_type</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type</span> <span class="ruby-identifier">type</span>, <span class="ruby-value">context:</span> <span class="ruby-keyword">nil</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type_params</span>(
          <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type_params</span>,
          <span class="ruby-value">type_name:</span> <span class="ruby-identifier">name</span>,
          <span class="ruby-value">location:</span> <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>&amp;.<span class="ruby-identifier">aref</span>(<span class="ruby-value">:type_params</span>)
        )

        <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">members</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">member</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">MethodDefinition</span>
            <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_method_definition</span>(<span class="ruby-identifier">member</span>, <span class="ruby-value">type_name:</span> <span class="ruby-identifier">name</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">env</span>.<span class="ruby-identifier">constant_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">const</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Validating constant: `#{name}`...&quot;</span>
        <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type</span> <span class="ruby-identifier">const</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type</span>, <span class="ruby-value">context:</span> <span class="ruby-identifier">const</span>.<span class="ruby-identifier">context</span>
        <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">ensure_namespace!</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">const</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">env</span>.<span class="ruby-identifier">global_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">global</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Validating global: `#{name}`...&quot;</span>
        <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type</span> <span class="ruby-identifier">global</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type</span>, <span class="ruby-value">context:</span> <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">env</span>.<span class="ruby-identifier">type_alias_decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">decl</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Validating alias: `#{name}`...&quot;</span>
        <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">expand_alias1</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type</span> <span class="ruby-identifier">type</span>, <span class="ruby-value">context:</span> <span class="ruby-keyword">nil</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_type_alias</span>(<span class="ruby-value">entry:</span> <span class="ruby-identifier">decl</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run_vendor" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run_vendor</span><span
                                class="method-args">(args, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run_vendor-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 877</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run_vendor</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">options</span>)
      <span class="ruby-identifier">clean</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-identifier">vendor_dir</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-string">&quot;vendor/sigs&quot;</span>)

      <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-identifier">&lt;&lt;-EOB</span>
<span class="ruby-value">Usage: rbs vendor [options...] [gems...]

Vendor signatures in the project directory.
This command ignores the RBS loading global options, `-r` and `-I`.

Examples:

  $ rbs vendor
  $ rbs vendor --vendor-dir=sig
  $ rbs vendor --no-stdlib

Options:
</span><span class="ruby-identifier">        EOB</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--[no-]clean&quot;</span>, <span class="ruby-string">&quot;Clean vendor directory (default: no)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">clean</span> = <span class="ruby-identifier">v</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">&quot;--vendor-dir [DIR]&quot;</span>, <span class="ruby-string">&quot;Specify the directory for vendored signatures (default: vendor/sigs)&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">vendor_dir</span> = <span class="ruby-constant">Pathname</span>(<span class="ruby-identifier">path</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">args</span>)

      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Vendoring signatures to #{vendor_dir}...&quot;</span>

      <span class="ruby-identifier">loader</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">loader</span>()

      <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gem</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">name</span>, <span class="ruby-identifier">version</span> = <span class="ruby-identifier">gem</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/:/</span>, <span class="ruby-value">2</span>)

        <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">name</span>

        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  Loading library: #{name}, version=#{version}...&quot;</span>
        <span class="ruby-identifier">loader</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">library:</span> <span class="ruby-identifier">name</span>, <span class="ruby-value">version:</span> <span class="ruby-identifier">version</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">vendorer</span> = <span class="ruby-constant">Vendorer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">vendor_dir:</span> <span class="ruby-identifier">vendor_dir</span>, <span class="ruby-value">loader:</span> <span class="ruby-identifier">loader</span>)

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">clean</span>
        <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;  Deleting #{vendor_dir}...&quot;</span>
        <span class="ruby-identifier">vendorer</span>.<span class="ruby-identifier">clean!</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;  Copying RBS files...&quot;</span>
      <span class="ruby-identifier">vendorer</span>.<span class="ruby-identifier">copy!</span>
    <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-test_opt" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">test_opt</span><span
                                class="method-args">(options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="test_opt-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/cli.rb, line 1025</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">test_opt</span> <span class="ruby-identifier">options</span>
  <span class="ruby-identifier">opts</span> = []

  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">push</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>.<span class="ruby-identifier">repos</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;--repo #{Shellwords.escape(dir)}&quot;</span>})
  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">push</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>.<span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;-I #{Shellwords.escape(dir)}&quot;</span>})
  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">push</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>.<span class="ruby-identifier">libs</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;-r#{Shellwords.escape(lib)}&quot;</span>})

  <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot; &quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

